<form name="frm" action="<?php echo $this->site['base_url']?>design/save" method="post" enctype="multipart/form-data" onsubmit="return validate()">
<table class="giaiphap" width="100%" border="0" cellspacing="2" cellpadding="0">
          <tr>
            <td style="padding-top:10px"><table class="item"width="100%" border="0">
              <tr>
                <td class="item_title" ><?php echo Kohana::lang('designs_lang.tt_page_title')?></td>
                </tr>
              <tr>
                <td class="item_content">
				<table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <tr>
				  
					<td valign="top">
					<?php 
				  $i=1;
				  foreach($mCate as $listcate) {
				  ?>
					<?php
					if($i%2!=0){ 
					?>
					
				<p class="gd_12 PT10"><b><?php echo $listcate['cate_design_title']?></b></p>
				<ul class="hlist1">
				<?php foreach($mDesigns as $list){
					if($list['cate_design_id']==$listcate['cate_design_id']){
				?>
				<li>
				<input name="txt_program[]" id="txt_program" type="checkbox" value="<?php echo $list['designs_id']?>" /><a href="<?php echo $this->site['base_url']?>design/detail/<?php echo $list['designs_id']?>"><?php echo $list['designs_title']?></a>
				</li>
				
				<?php 
						}
					}?>
					</ul>
				
				<?php 
					}
					$i++;
				} ?>
				</td>
				
				<td  valign="top">
				<?php 
				  $j=1;
				  foreach($mCate as $listcate) {
				  if($j%2==0) { ?>
				
				<p class="gd_12 PT10"><b><?php echo $listcate['cate_design_title']?></b></p>
				<ul class="hlist1">
				<?php foreach($mDesigns as $list){
					if($list['cate_design_id']==$listcate['cate_design_id']){
				?>
				<li>
				<input name="txt_program[]" id="txt_program" type="checkbox" value="<?php echo $list['designs_id']?>" />
				<a href="<?php echo $this->site['base_url']?>design/detail/<?php echo $list['designs_id']?>"><?php echo $list['designs_title']?></a>
				</li>
				
				<?php 
						}
					}?>
					</ul>
				<?php }
				$j++;
					}
					?></td>
					
				  </tr>
				</table>
			  </td>
                </tr>
				<tr><td>
					<table align="left" cellpadding="0" cellspacing="0" height="245" width="418">
                                <tbody><tr valign="baseline"> 
                                  <td align="right" nowrap="nowrap" width="36%"><font color="#000000"><?php echo Kohana::lang('design_lang.lbl_name')?>:</font></td>
                                  <td width="64%"><input name="Name" size="32" type="text"> 
                                  </td>
                                </tr>
                                <tr valign="baseline"> 
                                  <td align="right" nowrap="nowrap"><font color="#000000">Email:</font></td>
                                  <td><input name="Email" size="32" type="text"> 
                                  </td>
                                </tr>
                                <tr valign="baseline"> 
                                  <td align="right" nowrap="nowrap"><font color="#000000"><?php echo Kohana::lang('design_lang.lbl_organization')?>:</font></td>
                                  <td><input name="Organization" size="32" type="text"> 
                                  </td>
                                </tr>
                                <tr> 
                                  <td align="right" nowrap="nowrap" valign="top"><font color="#000000" face="Arial, Helvetica, sans-serif"><?php echo Kohana::lang('design_lang.lbl_address')?>:</font></td>
                                  <td valign="top"><textarea name="Address" cols="35" rows="4"></textarea> 
                                  </td>
                                </tr>
                                <tr valign="baseline"> 
                                  <td align="right" nowrap="nowrap"><font size="2" color="#000000" face="Arial, Helvetica, sans-serif"><?php echo Kohana::lang('design_lang.lbl_phone')?>:</font></td>
                                  <td><font size="2" color="#000000" face="Arial, Helvetica, sans-serif"> 
                                    <input name="Phone" size="32" type="text">
                                    </font></td>
                                </tr>
                                <tr valign="baseline"> 
                                  <td align="right" nowrap="nowrap"><font color="#000000"><?php echo Kohana::lang('design_lang.lbl_mobile')?>:</font></td>
                                  <td><input name="Mobile" size="32" type="text"></td>
                                </tr>
                                 <tr valign="baseline"> 
                                  <td align="right" nowrap="nowrap">&nbsp;</td>
                                  <td><font size="2" color="#000000" face="Arial, Helvetica, sans-serif"> 
                                    <input name="submit" value="   Submit   " type="submit">
                                    &nbsp;&nbsp; </font></td>
                                </tr>
                              </tbody></table>
				</td></tr>
              </table></td>
            </tr>
                 
        </table>
	 </form>
<script language="javascript">
function isFullName(val)	{
	var name1 = val;
	var regex_for_name	= /^[A-Za-z]+ [A-Za-z]+$/
	var alt_regex_for_name	= /^[A-Za-z]+$/
	if(   (name1.search(regex_for_name) != -1)  || (name1.search(alt_regex_for_name) != -1 ) ) {
			return true;
	}
	 else 
	{
	return	false;	
	}
}

function isAlphaNum(val)
	{
	var name1 = val;
	var regex_for_name	= /^[A-Za-z0-9]+ [A-Za-z0-9]+$/
	var alt_regex_for_name	= /^[A-Za-z0-9]+$/
	if(   (name1.search(regex_for_name) != -1)  || (name1.search(alt_regex_for_name) != -1 ) ) {
			return true;
	}
	 else
	  {
	return	false;	
	}
}

function isNum(val)
	{
	var name1 = val;
	var regex_for_name	= /^[0-9]+ [0-9]+$/
	var alt_regex_for_name	= /^[0-9]+$/
	if(   (name1.search(regex_for_name) != -1)  || (name1.search(alt_regex_for_name) != -1 ) ) {
			return true;
	}
	 else
	  {
	return	false;	
	}
}

function echeck(str)
 {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1)
		{
		   alert("Invalid Email Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid Email Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		{
		    alert("Invalid  email")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1)
		 {
		    alert("Invalid  email")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		 {
		    alert("Invalid  email")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1)
		 {
		    alert("Invalid  email")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1)
		 {
		    alert("Invalid  email")
		    return false
		 }

 		 return true					
	}

function validate()
{
	var cnt = -1;
	var frmName = document.frm;
	

	if (isFullName(frmName.Name.value) == false)
		{
		alert("Name is invalid");
		frmName.Name.focus();
		return false;
	}

	if (echeck(frmName.Email.value) == false)
		{
		frmName.Email.focus();
		return false;
	}

	if (isFullName(frmName.Organization.value) == false)	
	{
		alert("Organization is invalid");
		frmName.Organization.focus();
		return false;
	}


	if (isNum(frmName.Phone.value) == false)	
	{
		alert("Phone is invalid");
		frmName.Phone.focus();
		return false;
	}

	if (isNum(frmName.Mobile.value) == false)	
	{
		alert("Mobile is invalid");
		document.form1.Mobile.focus();
		return false;
	}
	if (isFullName(frmName.Location.value) == false)	
	{
		alert("Location is invalid");
		frmName.Location.focus();
		return false;
	}	
}
</script>